# Autor chenfeng
# !/usr/bin/env Python
# coding=utf-8

import json
import re

read_path = "admin.jsonl"
write_path = "self_relations.jsonl"
datas = []

with open(read_path, encoding='utf-8') as f:
    for line in f:
        data = json.loads(line)
        assert data is not None
        relations_ = data['relations']
        if relations_ is not None and len(relations_) > 0:
            datas.append(data)
    f.close()

print(len(datas))

with open(write_path, 'w+', encoding='utf-8') as f_w:
    for data in datas:
        data_ = re.compile("'").sub('"', str(data))
        f_w.write(data_ + '\n')
    f_w.close()

